home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Science / RLaB / examples / humps.r < prev    next >
Text File  |  1994-04-25  |  600b  |  27 lines

  1. //
  2. //  Write a function that evaluates a mathematical function.
  3. //
  4.  
  5. humps = function(x) 
  6. {
  7.   return (1 ./ ((x-.3).^2 + .01) + 1 ./ ((x-.9).^2 + .04) - 6);
  8. }
  9.  
  10. //
  11. //  The following statements: 
  12. //  Create a vector of the independent variable.
  13.  
  14. //  x = -1:2:.01;
  15.  
  16. //
  17. //  Evaluate the function over the specified interval,
  18. //  and write out the result in one statement.
  19.  
  20. //  write("humps-data"; [x; humps(x)]')
  21.  
  22. //
  23. //  `hump(x)' evaluates the the function for x.
  24. //  `[x; hump(x)]'' forms a matrix with the independent variable (x)
  25. //  as the 1st column, and the evaluated function as the 2nd column.
  26. //
  27.